Repository navigation
Fix process output truncation at embedded NUL bytes - #253
Merged
Merged
Conversation
Append the exact ReadFile byte count so embedded NULs reach the existing formatter without truncating data or merging records. Add JSON/XML pipe regressions covering NUL positions, read boundaries, UTF-8, and final partial-line flushing.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the byte-preserving process-output change.
No open issues 🎉
What changed in this PR
Fixes #249 in LogMonitor’s process-output pipeline by preserving every byte returned by pipe reads. Embedded NULs can then reach the existing JSON/XML formatter without truncating text or merging separate records.
Changes:
- Replace C-string buffering with byte-counted appends and remove the unused buffer terminator.
- Add JSON/XML regressions covering embedded NULs, 4096-byte read boundaries, UTF-8, separate records, and partial-line flushing at explicit EOF.
- Restore shared test state and close test-owned pipe handles. Existing CRLF and shutdown behavior remain unchanged.
| File | Description |
|---|---|
LogMonitor/src/LogMonitor/ProcessMonitor.cpp |
Preserve the complete pipe-read buffer, including embedded NULs. |
LogMonitor/LogMonitorTests/LogMonitorTests.cpp |
Add production pipe-reader regressions with output capture and resource cleanup. |
Review effort: Max
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #249.
ReadFile, rather than treating each process-pipe buffer as a NUL-terminated C string.?without dropping following text or merging independent records.ReadFromPipeimplementation. Cover NULs within lines and at 4096-byte read boundaries, UTF-8 preservation, separate records, and the final partial-line flush when pipe EOF is explicitly signaled. Restore standard-output/global state and close owned test handles.The reported reproduction now retains two records:
Local validation
The two new pipe regressions failed on unchanged main production code before the fix and passed afterward. The original issue was also reproduced with the saved baseline executable.
Stress coverage includes NUL positions, read/write boundaries, valid and invalid UTF-8, stdout/stderr and alternating writes, 1 MiB lines, 5,000-record bursts, deterministic randomized inputs, and child exit codes 0, 37, and 255.
Container validation used process isolation on Server Core
ltsc2025(native x64/x86 and CMake x64) and Nano Serverltsc2022(native/CMake x64), testing both JSON and XML. The native x86 executable's existing VC++ runtime dependency was supplied app-locally in its fixture. Nano ran asContainerAdministratorto execute the host bind-mounted fixture; host permissions were not changed.Native Debug builds still emit the pre-existing
STL4038warning about including<variant>without C++17. No compiler errors occurred. Test-owned containers, processes, and the Log Monitor ETW session were cleaned up.Scope and follow-ups
Extensive testing confirmed two unchanged baseline limitations, now tracked separately:
This PR does not change shutdown behavior, formatter policy, release versioning, or published release artifacts.